## The Meggitt table of the binary Golay code [23,12,7]


from PyM import *


n = 23; R = range(n-1)
R2 = [(i,j) for i in R for j in R if j<i]


[_,x] = polynomial_ring(Zn(2),'x')

g = x**11+x**9+x**7+x**6+x**5+x+1

# Megit table, as a list of pairs
E1 = [(remainder(x**(n-1),g),x**(n-1))]

E2 = [(remainder(x**(n-1)+x**i,g),x**(n-1)+x**i) for i in R]

E3 = [(remainder(x**(n-1)+x**i+x**j,g),x**(n-1)+x**i+x**j) for (i,j) in R2]

E = E1+E2+E3

def lookup(k,T):
    for (a,b) in T:
        if a==k: return b
    return 0

# Example
s = remainder(x**(n-1)+x**14+x**3,g)

show(s)

show(lookup(s,E))


